package aurelienribon.texturepackergui;

import aurelienribon.ui.components.ArStyle;
import aurelienribon.ui.components.PaintedPanel;
import aurelienribon.ui.css.Style;
import aurelienribon.ui.css.swing.SwingStyle;
import aurelienribon.utils.Res;
import aurelienribon.utils.notifications.AutoListModel;
import aurelienribon.utils.notifications.ObservableList;

import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.tools.imagepacker.TexturePacker2.Settings;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;

import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.filechooser.FileFilter;

public class MainWindow extends JFrame {
  private final Canvas canvas;
  private final ObservableList<Pack> packs = new ObservableList<Pack>();
  private File lastDir = new File(".");

  public MainWindow(final Canvas canvas, Component canvasCmp) {
    try {
      Font font1 = Font.createFont(Font.TRUETYPE_FONT, Res.getStream("fonts/SquareFont.ttf"));
      GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(font1);
    } catch (FontFormatException ex) {
    } catch (IOException ex) {
    }

    this.canvas = canvas;

    canvas.setCallback(new Canvas.Callback() {
      @Override
      public void atlasError() {
        JOptionPane.showMessageDialog(MainWindow.this, "Impossible to create the atlas in libgdx canvas, sorry.");
      }
    });

    setContentPane(new PaintedPanel());
    getContentPane().setLayout(new BorderLayout());
    initComponents();
    renderPanel.add(canvasCmp, BorderLayout.CENTER);

    newPackBtn.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        newPack();
      }
    });
    renamePackBtn.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        renamePack();
      }
    });
    deletePackBtn.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        deletePack();
      }
    });
    moveUpPackBtn.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        moveUp();
      }
    });
    moveDownPackBtn.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        moveDown();
      }
    });
    openProjectBtn.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        loadProject();
      }
    });
    saveProjectBtn.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        saveProject();
      }
    });
    browseInputBtn.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        browseInput();
      }
    });
    browseOutputBtn.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        browseOutput();
      }
    });
    packSelectedBtn.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        packSelected();
      }
    });
    packAllBtn.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        packAll();
      }
    });
    copySettingsBtn.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        copySettingsToAll();
      }
    });

    packsList.setModel(new AutoListModel<Pack>(packs));
    packsList.setCellRenderer(packsListCellRenderer);
    packsList.addListSelectionListener(packsListSelectionListener);
    packsListSelectionListener.valueChanged(null);

    SwingStyle.init();
    ArStyle.init();
    Style.registerCssClasses(getContentPane(), ".rootPanel");
    Style.registerCssClasses(projectPanel, ".titledPanel", "#projectPanel");
    Style.registerCssClasses(settingsPanel, ".titledPanel", "#settingsPanel");
    Style.registerCssClasses(renderPanel, ".titledPanel", "#renderPanel");
    Style.registerCssClasses(headerPanel, ".headerPanel");
    Style.registerCssClasses(headerPanel1, ".headerPanel");
    Style.registerCssClasses(jScrollPane1, ".listPanel");
    Style.registerCssClasses(commentLabel, ".comment");
    Style.registerCssClasses(versionLabel, ".versionLabel");
    Style.apply(getContentPane(), new Style(Res.getUrl("css/style.css")));

    versionLabel.initAndCheck("3.2.0", null,
      "http://www.aurelienribon.com/projects/libgdx-texturepacker-gui/versions.txt",
      "http://code.google.com/p/libgdx-texturepacker-gui/");
  }

  public void load(File file) throws IOException {
    packs.replaceBy(Pack.parse(file));
    if (packs.isEmpty()) packsList.clearSelection();
    else packsList.setSelectedIndex(0);
  }

  private final ListCellRenderer packsListCellRenderer = new DefaultListCellRenderer() {
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      Pack pack = (Pack) value;
      JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
      label.setText(pack.getName());
      return label;
    }
  };

  private final ListSelectionListener packsListSelectionListener = new ListSelectionListener() {
    private Pack selectedPack;

    @Override
    public void valueChanged(ListSelectionEvent e) {
      Pack pack = (Pack) packsList.getSelectedValue();
      if (selectedPack != null) savePack(selectedPack);
      selectedPack = pack;

      renamePackBtn.setEnabled(pack != null);
      deletePackBtn.setEnabled(pack != null);
      moveUpPackBtn.setEnabled(pack != null);
      moveDownPackBtn.setEnabled(pack != null);
      inputField.setEnabled(pack != null);
      outputField.setEnabled(pack != null);
      filenameField.setEnabled(pack != null);
      browseInputBtn.setEnabled(pack != null);
      browseOutputBtn.setEnabled(pack != null);
      packSelectedBtn.setEnabled(pack != null);
      packAllBtn.setEnabled(pack != null);
      enable(settingsPanel, pack != null);

      if (pack != null) {
        loadPack(pack);
        canvas.requestPackReload(pack.getOutput() + "/" + pack.getFilename());
      } else {
        inputField.setText("");
        outputField.setText("");
        filenameField.setText("");
        canvas.requestPackReload(null);
      }
    }
  };

  private void newPack() {
    Pack pack = new Pack();
    String name = JOptionPane.showInputDialog(this, "Name of the pack?", "");
    if (name != null) {
      pack.setName(name);
      packs.add(pack);
      packsList.setSelectedValue(pack, true);
    }
  }

  private void renamePack() {
    Pack pack = (Pack) packsList.getSelectedValue();
    String name = JOptionPane.showInputDialog(this, "New name of the pack?", pack.getName());
    if (name != null) pack.setName(name);
  }

  private void deletePack() {
    Pack pack = (Pack) packsList.getSelectedValue();
    packs.remove(pack);
    packsList.clearSelection();
  }

  private void moveUp() {
    Pack pack = (Pack) packsList.getSelectedValue();
    int idx = packs.indexOf(pack);
    if (idx > 0) {
      Pack pack2 = packs.get(idx - 1);
      packs.set(idx - 1, pack);
      packs.set(idx, pack2);
      packsList.setSelectedValue(pack, true);
    }
  }

  private void moveDown() {
    Pack pack = (Pack) packsList.getSelectedValue();
    int idx = packs.indexOf(pack);
    if (idx < packs.size() - 1) {
      Pack pack2 = packs.get(idx + 1);
      packs.set(idx + 1, pack);
      packs.set(idx, pack2);
      packsList.setSelectedValue(pack, true);
    }
  }

  private void loadProject() {
    JFileChooser chooser = new JFileChooser(lastDir);
    chooser.setDialogTitle("Select your project file");

    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      try {
        File file = chooser.getSelectedFile();
        lastDir = file.getParentFile();
        packs.replaceBy(Pack.parse(file));
        if (packs.isEmpty()) packsList.clearSelection();
        else packsList.setSelectedIndex(0);
      } catch (IOException ex) {
        JOptionPane.showMessageDialog(this, "Project file cannot be read.");
      }
    }
  }

  private void saveProject() {
    Pack pack = (Pack) packsList.getSelectedValue();
    if (pack != null) savePack(pack);

    JFileChooser chooser = new JFileChooser(lastDir);
    chooser.setDialogTitle("Select your project file");

    if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
      try {
        File file = chooser.getSelectedFile();
        lastDir = file.getParentFile();
        Pack.export(file, packs);
        JOptionPane.showMessageDialog(this, "Save done.");
      } catch (IOException ex) {
        JOptionPane.showMessageDialog(this, "Project file cannot be written to.");
      }
    }
  }

  private void browseInput() {
    JFileChooser chooser = new JFileChooser(lastDir);
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setFileFilter(new FileFilter() {
      @Override
      public boolean accept(File f) {
        return f.isDirectory();
      }

      @Override
      public String getDescription() {
        return "Directories";
      }
    });

    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      File file = chooser.getSelectedFile();
      lastDir = file;
      inputField.setText(file.getPath());
    }
  }

  private void browseOutput() {
    JFileChooser chooser = new JFileChooser(lastDir);
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setFileFilter(new FileFilter() {
      @Override
      public boolean accept(File f) {
        return f.isDirectory();
      }

      @Override
      public String getDescription() {
        return "Directories";
      }
    });

    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      File file = chooser.getSelectedFile();
      lastDir = file;
      outputField.setText(file.getPath());
    }
  }

  private void packSelected() {
    Pack pack = (Pack) packsList.getSelectedValue();
    savePack(pack);

    PackDialog dialog = new PackDialog(this);
    dialog.launchPack(pack);
    dialog.setLocationRelativeTo(this);
    dialog.setVisible(true);

    canvas.requestPackReload(pack.getOutput() + "/" + pack.getFilename());
  }

  private void packAll() {
    Pack pack = (Pack) packsList.getSelectedValue();
    savePack(pack);

    PackDialog dialog = new PackDialog(this);
    dialog.launchPack(packs);
    dialog.setLocationRelativeTo(this);
    dialog.setVisible(true);

    canvas.requestPackReload(pack.getOutput() + "/" + pack.getFilename());
  }

  private void copySettingsToAll() {
    Pack pack = (Pack) packsList.getSelectedValue();
    savePack(pack);

    String settings = pack.exportSettings();
    for (Pack pack2 : packs) pack2.importSettings(settings);

    JOptionPane.showMessageDialog(this, "Successful! All packs now use the current settings.");
  }

  private void loadPack(Pack pack) {
    inputField.setText(pack.getInput());
    outputField.setText(pack.getOutput());
    filenameField.setText(pack.getRawFilename());

    Settings settings = pack.getSettings();

    opt_alias_chk.setSelected(settings.alias);
    opt_alphaThreashold_nud.setValue(settings.alphaThreshold);
    opt_debug_chk.setSelected(settings.debug);
    opt_duplicatePadding_chk.setSelected(settings.duplicatePadding);
    opt_edgePadding_chk.setSelected(settings.edgePadding);
    opt_fast_chk.setSelected(settings.fast);
    opt_filterMag_cbox.setSelectedItem(settings.filterMag.toString());
    opt_filterMin_cbox.setSelectedItem(settings.filterMin.toString());
    opt_format_cbox.setSelectedItem(settings.format.toString());
    opt_ignoreBlankImages_chk.setSelected(settings.ignoreBlankImages);
    opt_ignoreIndices_chk.setSelected(settings.ignoreIndices);
    opt_keepExtensions_chk.setSelected(settings.keepExtensions);
    opt_combineSubdirectories_chk.setSelected(settings.combineSubdirectories);
    opt_jsonOutput_chk.setSelected(settings.jsonOutput);
    opt_flattenPaths_chk.setSelected(settings.flattenPaths);
    opt_jpegQuality_nud.setValue(settings.jpegQuality);
    opt_maxPageHeight_nud.setValue(settings.maxHeight);
    opt_maxPageWidth_nud.setValue(settings.maxWidth);
    opt_minPageHeight_nud.setValue(settings.minHeight);
    opt_minPageWidth_nud.setValue(settings.minWidth);
    opt_outputFormat_cbox.setSelectedItem(settings.outputFormat.toString());
    opt_paddingX_nud.setValue(settings.paddingX);
    opt_paddingX_nud.setValue(settings.paddingY);
    opt_pot_chk.setSelected(settings.pot);
    opt_rotation_chk.setSelected(settings.rotation);
    opt_stripWhitespaceX_chk.setSelected(settings.stripWhitespaceX);
    opt_stripWhitespaceY_chk.setSelected(settings.stripWhitespaceY);
    opt_wrapX_cbox.setSelectedItem(settings.wrapX);
    opt_wrapY_cbox.setSelectedItem(settings.wrapY);
  }

  private void savePack(Pack pack) {
    pack.setInput(inputField.getText().trim());
    pack.setOutput(outputField.getText().trim());
    pack.setFilename(filenameField.getText().trim());

    Settings settings = pack.getSettings();

    settings.alias = opt_alias_chk.isSelected();
    settings.alphaThreshold = (Integer) opt_alphaThreashold_nud.getValue();
    settings.debug = opt_debug_chk.isSelected();
    settings.duplicatePadding = opt_duplicatePadding_chk.isSelected();
    settings.edgePadding = opt_edgePadding_chk.isSelected();
    settings.fast = opt_fast_chk.isSelected();
    settings.filterMag = TextureFilter.valueOf((String) opt_filterMag_cbox.getSelectedItem());
    settings.filterMin = TextureFilter.valueOf((String) opt_filterMin_cbox.getSelectedItem());
    settings.format = Format.valueOf((String) opt_format_cbox.getSelectedItem());
    settings.ignoreBlankImages = opt_ignoreBlankImages_chk.isSelected();
    settings.ignoreIndices = opt_ignoreIndices_chk.isSelected();
    settings.keepExtensions = opt_keepExtensions_chk.isSelected();
    settings.combineSubdirectories = opt_combineSubdirectories_chk.isSelected();
    settings.jsonOutput = opt_jsonOutput_chk.isSelected();
    settings.flattenPaths = opt_flattenPaths_chk.isSelected();
    settings.jpegQuality = (Float) opt_jpegQuality_nud.getValue();
    settings.maxHeight = (Integer) opt_maxPageHeight_nud.getValue();
    settings.maxWidth = (Integer) opt_maxPageWidth_nud.getValue();
    settings.minHeight = (Integer) opt_minPageHeight_nud.getValue();
    settings.minWidth = (Integer) opt_minPageWidth_nud.getValue();
    settings.outputFormat = (String) opt_outputFormat_cbox.getSelectedItem();
    settings.paddingX = (Integer) opt_paddingX_nud.getValue();
    settings.paddingY = (Integer) opt_paddingY_nud.getValue();
    settings.pot = opt_pot_chk.isSelected();
    settings.rotation = opt_rotation_chk.isSelected();
    settings.stripWhitespaceX = opt_stripWhitespaceX_chk.isSelected();
    settings.stripWhitespaceY = opt_stripWhitespaceY_chk.isSelected();
    settings.wrapX = TextureWrap.valueOf((String) opt_wrapX_cbox.getSelectedItem());
    settings.wrapY = TextureWrap.valueOf((String) opt_wrapY_cbox.getSelectedItem());
  }

  private void enable(Component cmp, boolean value) {
    cmp.setEnabled(value);
    if (cmp instanceof Container) {
      Container c = (Container) cmp;
      for (Component child : c.getComponents()) enable(child, value);
    }
  }

  // -------------------------------------------------------------------------
  // Generated stuff
  // -------------------------------------------------------------------------

  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    configPanel = new JPanel();
    projectPanel = new JPanel();
    headerPanel = new JPanel();
    jToolBar1 = new JToolBar();
    newPackBtn = new JButton();
    renamePackBtn = new JButton();
    deletePackBtn = new JButton();
    moveUpPackBtn = new JButton();
    moveDownPackBtn = new JButton();
    jToolBar2 = new JToolBar();
    openProjectBtn = new JButton();
    saveProjectBtn = new JButton();
    jPanel2 = new JPanel();
    packAllBtn = new JButton();
    jPanel1 = new JPanel();
    jLabel11 = new JLabel();
    inputField = new JTextField();
    outputField = new JTextField();
    browseOutputBtn = new JButton();
    filenameField = new JTextField();
    jLabel12 = new JLabel();
    browseInputBtn = new JButton();
    jLabel1 = new JLabel();
    packSelectedBtn = new JButton();
    jScrollPane1 = new JScrollPane();
    packsList = new JList();
    commentLabel = new JLabel();
    settingsPanel = new JPanel();
    headerPanel1 = new JPanel();
    jToolBar4 = new JToolBar();
    copySettingsBtn = new JButton();
    jPanel3 = new JPanel();
    opt_minPageHeight_lbl = new JLabel();
    opt_minPageHeight_nud = new JSpinner();
    opt_pot_chk = new JCheckBox();
    opt_duplicatePadding_chk = new JCheckBox();
    opt_alias_chk = new JCheckBox();
    opt_minPageWidth_nud = new JSpinner();
    opt_maxPageWidth_nud = new JSpinner();
    opt_ignoreBlankImages_chk = new JCheckBox();
    opt_ignoreIndices_chk = new JCheckBox();
    opt_keepExtensions_chk = new JCheckBox();
    opt_combineSubdirectories_chk = new JCheckBox();
    opt_jsonOutput_chk = new JCheckBox();
    opt_flattenPaths_chk = new JCheckBox();
    opt_maxPageWidth_lab = new JLabel();
    opt_alphaThreashold_nud = new JSpinner();
    opt_debug_chk = new JCheckBox();
    opt_fast_chk = new JCheckBox();
    opt_jpegQuality_lbl = new JLabel();
    opt_stripWhitespaceY_chk = new JCheckBox();
    opt_paddingX_lbl = new JLabel();
    opt_rotation_chk = new JCheckBox();
    opt_minPageWidth_lbl = new JLabel();
    opt_alphaThresholt_lbl = new JLabel();
    opt_edgePadding_chk = new JCheckBox();
    opt_paddingX_nud = new JSpinner();
    opt_maxPageHeight_lbl = new JLabel();
    opt_maxPageHeight_nud = new JSpinner();
    opt_jpegQuality_nud = new JSpinner();
    opt_format_cbox = new JComboBox();
    opt_filterMin_cbox = new JComboBox();
    opt_outputFormat_cbox = new JComboBox();
    opt_filterMag_cbox = new JComboBox();
    opt_filterMag_lbl = new JLabel();
    opt_filterMin_lbl = new JLabel();
    opt_format_lbl = new JLabel();
    opt_outputFormat_lbl = new JLabel();
    opt_paddingY_lbl = new JLabel();
    opt_paddingY_nud = new JSpinner();
    opt_wrapY_lbl = new JLabel();
    opt_wrapX_lbl = new JLabel();
    opt_wrapX_cbox = new JComboBox();
    opt_wrapY_cbox = new JComboBox();
    opt_stripWhitespaceX_chk = new JCheckBox();
    versionLabel = new aurelienribon.utils.VersionLabel();
    centerPanel = new JPanel();
    renderPanel = new JPanel();

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("GDX Texture Packer");

    configPanel.setOpaque(false);

    projectPanel.setLayout(new BorderLayout());

    headerPanel.setLayout(new BorderLayout());

    jToolBar1.setFloatable(false);
    jToolBar1.setRollover(true);
    jToolBar1.setOpaque(false);

    newPackBtn.setIcon(new ImageIcon(getClass().getResource("/res/gfx/ic_add.png"))); // NOI18N
    newPackBtn.setText("New pack");
    newPackBtn.setToolTipText("Add a new pack to the list");
    newPackBtn.setFocusable(false);
    newPackBtn.setVerticalTextPosition(SwingConstants.BOTTOM);
    jToolBar1.add(newPackBtn);

    renamePackBtn.setIcon(new ImageIcon(getClass().getResource("/res/gfx/ic_edit.png"))); // NOI18N
    renamePackBtn.setToolTipText("Rename the selected pack");
    renamePackBtn.setFocusable(false);
    jToolBar1.add(renamePackBtn);

    deletePackBtn.setIcon(new ImageIcon(getClass().getResource("/res/gfx/ic_delete.png"))); // NOI18N
    deletePackBtn.setToolTipText("Delete the selected pack");
    deletePackBtn.setFocusable(false);
    deletePackBtn.setVerticalTextPosition(SwingConstants.BOTTOM);
    jToolBar1.add(deletePackBtn);

    moveUpPackBtn.setIcon(new ImageIcon(getClass().getResource("/res/gfx/ic_up.png"))); // NOI18N
    moveUpPackBtn.setToolTipText("Move the selected pack up in the list");
    moveUpPackBtn.setFocusable(false);
    moveUpPackBtn.setHorizontalTextPosition(SwingConstants.CENTER);
    moveUpPackBtn.setVerticalTextPosition(SwingConstants.BOTTOM);
    jToolBar1.add(moveUpPackBtn);

    moveDownPackBtn.setIcon(new ImageIcon(getClass().getResource("/res/gfx/ic_down.png"))); // NOI18N
    moveDownPackBtn.setToolTipText("Move the selected pack down in the list");
    moveDownPackBtn.setFocusable(false);
    moveDownPackBtn.setHorizontalTextPosition(SwingConstants.CENTER);
    moveDownPackBtn.setVerticalTextPosition(SwingConstants.BOTTOM);
    jToolBar1.add(moveDownPackBtn);

    headerPanel.add(jToolBar1, BorderLayout.CENTER);

    jToolBar2.setFloatable(false);
    jToolBar2.setRollover(true);

    openProjectBtn.setIcon(new ImageIcon(getClass().getResource("/res/gfx/ic_open.png"))); // NOI18N
    openProjectBtn.setText("Open project");
    openProjectBtn.setToolTipText("");
    openProjectBtn.setFocusable(false);
    openProjectBtn.setHorizontalAlignment(SwingConstants.LEFT);
    openProjectBtn.setMargin(new Insets(2, 3, 2, 3));
    jToolBar2.add(openProjectBtn);

    saveProjectBtn.setIcon(new ImageIcon(getClass().getResource("/res/gfx/ic_save.png"))); // NOI18N
    saveProjectBtn.setText("Save project");
    saveProjectBtn.setFocusable(false);
    saveProjectBtn.setHorizontalAlignment(SwingConstants.LEFT);
    saveProjectBtn.setMargin(new Insets(2, 3, 2, 3));
    jToolBar2.add(saveProjectBtn);

    headerPanel.add(jToolBar2, BorderLayout.EAST);

    projectPanel.add(headerPanel, BorderLayout.NORTH);

    jPanel2.setOpaque(false);

    packAllBtn.setIcon(new ImageIcon(getClass().getResource("/res/gfx/ic_pack.png"))); // NOI18N
    packAllBtn.setText("Pack'em all");
    packAllBtn.setMargin(new Insets(2, 3, 2, 3));

    jPanel1.setOpaque(false);

    jLabel11.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel11.setText("Output directory:");

    inputField.setColumns(10);

    outputField.setColumns(10);

    browseOutputBtn.setText("...");
    browseOutputBtn.setMargin(new Insets(2, 3, 2, 2));
    browseOutputBtn.setOpaque(false);

    filenameField.setColumns(10);

    jLabel12.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel12.setText("File name:");

    browseInputBtn.setText("...");
    browseInputBtn.setMargin(new Insets(2, 3, 2, 2));
    browseInputBtn.setOpaque(false);

    jLabel1.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel1.setText("Input directory:");

    GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
      jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
          .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
            .addComponent(jLabel12, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabel1, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabel11, GroupLayout.Alignment.LEADING))
          .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
          .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
              .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addComponent(outputField, GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
                .addComponent(inputField))
              .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
              .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                .addComponent(browseInputBtn)
                .addComponent(browseOutputBtn)))
            .addComponent(filenameField)))
    );
    jPanel1Layout.setVerticalGroup(
      jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
          .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(inputField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
            .addComponent(browseInputBtn)
            .addComponent(jLabel1))
          .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
          .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(jLabel11)
            .addComponent(outputField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
            .addComponent(browseOutputBtn))
          .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
          .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(jLabel12)
            .addComponent(filenameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
    );

    packSelectedBtn.setIcon(new ImageIcon(getClass().getResource("/res/gfx/ic_pack.png"))); // NOI18N
    packSelectedBtn.setText("Pack selected");
    packSelectedBtn.setMargin(new Insets(2, 3, 2, 3));

    packsList.setModel(new AbstractListModel() {
      String[] strings = {"Item 1", "Item 2", "Item 3", "Item 4", "Item 5"};

      public int getSize() {
        return strings.length;
      }

      public Object getElementAt(int i) {
        return strings[i];
      }
    });
    packsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    jScrollPane1.setViewportView(packsList);

    commentLabel.setText("Leave blank for \"<packname>.pack\"");

    GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
      jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(jPanel2Layout.createSequentialGroup()
          .addContainerGap()
          .addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
              .addComponent(packAllBtn)
              .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
              .addComponent(packSelectedBtn, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createSequentialGroup()
              .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 126, GroupLayout.PREFERRED_SIZE)
              .addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                  .addGap(10, 10, 10)
                  .addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGroup(jPanel2Layout.createSequentialGroup()
                  .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                  .addComponent(commentLabel)))))
          .addContainerGap())
    );
    jPanel2Layout.setVerticalGroup(
      jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(jPanel2Layout.createSequentialGroup()
          .addContainerGap()
          .addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
            .addGroup(jPanel2Layout.createSequentialGroup()
              .addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
              .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
              .addComponent(commentLabel))
            .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
          .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
          .addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(packSelectedBtn)
            .addComponent(packAllBtn))
          .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    projectPanel.add(jPanel2, BorderLayout.CENTER);

    settingsPanel.setLayout(new BorderLayout());

    headerPanel1.setLayout(new BorderLayout());

    jToolBar4.setFloatable(false);
    jToolBar4.setRollover(true);

    copySettingsBtn.setIcon(new ImageIcon(getClass().getResource("/res/gfx/ic_copy.png"))); // NOI18N
    copySettingsBtn.setText("Copy settings to all packs");
    copySettingsBtn.setFocusable(false);
    copySettingsBtn.setHorizontalAlignment(SwingConstants.LEFT);
    copySettingsBtn.setMargin(new Insets(2, 3, 2, 3));
    jToolBar4.add(copySettingsBtn);

    headerPanel1.add(jToolBar4, BorderLayout.WEST);

    settingsPanel.add(headerPanel1, BorderLayout.NORTH);

    jPanel3.setOpaque(false);

    opt_minPageHeight_lbl.setHorizontalAlignment(SwingConstants.RIGHT);
    opt_minPageHeight_lbl.setText("Min page height");

    opt_minPageHeight_nud.setModel(new SpinnerNumberModel(Integer.valueOf(16), Integer.valueOf(0), null, Integer.valueOf(1)));

    opt_pot_chk.setText("Force PoT");
    opt_pot_chk.setOpaque(false);

    opt_duplicatePadding_chk.setText("Duplicate padding");
    opt_duplicatePadding_chk.setOpaque(false);

    opt_alias_chk.setText("Use aliases");
    opt_alias_chk.setOpaque(false);

    opt_minPageWidth_nud.setModel(new SpinnerNumberModel(Integer.valueOf(16), Integer.valueOf(0), null, Integer.valueOf(1)));

    opt_maxPageWidth_nud.setModel(new SpinnerNumberModel(Integer.valueOf(512), Integer.valueOf(0), null, Integer.valueOf(1)));

    opt_ignoreBlankImages_chk.setText("Ignore blank imgs");
    opt_ignoreBlankImages_chk.setOpaque(false);

    opt_ignoreIndices_chk.setText("Ignore indices");
    opt_ignoreIndices_chk.setOpaque(false);

    opt_keepExtensions_chk.setText("Keep extensions");
    opt_keepExtensions_chk.setOpaque(false);

    opt_combineSubdirectories_chk.setText("Combine subdirectories");
    opt_combineSubdirectories_chk.setOpaque(false);

    opt_jsonOutput_chk.setText("JSON output");
    opt_jsonOutput_chk.setOpaque(false);

    opt_flattenPaths_chk.setText("Flatten paths");
    opt_flattenPaths_chk.setOpaque(false);

    opt_maxPageWidth_lab.setHorizontalAlignment(SwingConstants.RIGHT);
    opt_maxPageWidth_lab.setText("Max page width");

    opt_alphaThreashold_nud.setModel(new SpinnerNumberModel(0, 0, 255, 1));

    opt_debug_chk.setText("Debug");
    opt_debug_chk.setOpaque(false);

    opt_fast_chk.setText("Use fast algorithm");
    opt_fast_chk.setOpaque(false);

    opt_jpegQuality_lbl.setHorizontalAlignment(SwingConstants.RIGHT);
    opt_jpegQuality_lbl.setText("Jpeg quality");

    opt_stripWhitespaceY_chk.setText("Strip whitespace Y");
    opt_stripWhitespaceY_chk.setOpaque(false);

    opt_paddingX_lbl.setHorizontalAlignment(SwingConstants.RIGHT);
    opt_paddingX_lbl.setText("PaddingX");

    opt_rotation_chk.setText("Allow rotations");
    opt_rotation_chk.setOpaque(false);

    opt_minPageWidth_lbl.setHorizontalAlignment(SwingConstants.RIGHT);
    opt_minPageWidth_lbl.setText("Min page width");

    opt_alphaThresholt_lbl.setHorizontalAlignment(SwingConstants.RIGHT);
    opt_alphaThresholt_lbl.setText("Alpha threshold");

    opt_edgePadding_chk.setText("Edge padding");
    opt_edgePadding_chk.setOpaque(false);

    opt_paddingX_nud.setModel(new SpinnerNumberModel(Integer.valueOf(2), Integer.valueOf(0), null, Integer.valueOf(1)));

    opt_maxPageHeight_lbl.setHorizontalAlignment(SwingConstants.RIGHT);
    opt_maxPageHeight_lbl.setText("Max page height");

    opt_maxPageHeight_nud.setModel(new SpinnerNumberModel(Integer.valueOf(512), Integer.valueOf(0), null, Integer.valueOf(1)));

    opt_jpegQuality_nud.setModel(new SpinnerNumberModel(Float.valueOf(0.0f), Float.valueOf(0.0f), Float.valueOf(1.0f), Float.valueOf(0.05f)));

    opt_format_cbox.setModel(new DefaultComboBoxModel(new String[]{"RGBA8888", "RGBA4444", "RGB888", "RGB565", "Alpha", "LuminanceAlpha", "Intensity"}));
    opt_format_cbox.setOpaque(false);

    opt_filterMin_cbox.setModel(new DefaultComboBoxModel(new String[]{"Nearest", "Linear", "MipMap", "MipMapNearestNearest", "MipMapNearestLinear", "MipMapLinearNearest", "MipMapLinearLinear"}));
    opt_filterMin_cbox.setOpaque(false);

    opt_outputFormat_cbox.setModel(new DefaultComboBoxModel(new String[]{"png", "jpg"}));
    opt_outputFormat_cbox.setOpaque(false);

    opt_filterMag_cbox.setModel(new DefaultComboBoxModel(new String[]{"Nearest", "Linear", "MipMap", "MipMapNearestNearest", "MipMapNearestLinear", "MipMapLinearNearest", "MipMapLinearLinear"}));
    opt_filterMag_cbox.setOpaque(false);

    opt_filterMag_lbl.setHorizontalAlignment(SwingConstants.RIGHT);
    opt_filterMag_lbl.setText("Mag filter");

    opt_filterMin_lbl.setHorizontalAlignment(SwingConstants.RIGHT);
    opt_filterMin_lbl.setText("Min filter");

    opt_format_lbl.setHorizontalAlignment(SwingConstants.RIGHT);
    opt_format_lbl.setText("Output format");

    opt_outputFormat_lbl.setHorizontalAlignment(SwingConstants.RIGHT);
    opt_outputFormat_lbl.setText("Encoding format");

    opt_paddingY_lbl.setHorizontalAlignment(SwingConstants.RIGHT);
    opt_paddingY_lbl.setText("PaddingY");

    opt_paddingY_nud.setModel(new SpinnerNumberModel(Integer.valueOf(2), Integer.valueOf(0), null, Integer.valueOf(1)));

    opt_wrapY_lbl.setHorizontalAlignment(SwingConstants.RIGHT);
    opt_wrapY_lbl.setText("WrapX");

    opt_wrapX_lbl.setHorizontalAlignment(SwingConstants.RIGHT);
    opt_wrapX_lbl.setText("WrapY");

    opt_wrapX_cbox.setModel(new DefaultComboBoxModel(new String[]{"ClampToEdge", "Repeat"}));
    opt_wrapX_cbox.setOpaque(false);

    opt_wrapY_cbox.setModel(new DefaultComboBoxModel(new String[]{"ClampToEdge", "Repeat"}));
    opt_wrapY_cbox.setOpaque(false);

    opt_stripWhitespaceX_chk.setText("Strip whitespace X");
    opt_stripWhitespaceX_chk.setOpaque(false);

    JScrollPane jPanel3ScrollPane = new JScrollPane(jPanel3);
    settingsPanel.add(jPanel3ScrollPane, BorderLayout.CENTER);
    jPanel3ScrollPane.setPreferredSize(new Dimension(400, 400));

    GroupLayout jPanel3Layout = new GroupLayout(jPanel3);
    jPanel3.setLayout(jPanel3Layout);
    jPanel3Layout.setHorizontalGroup(
      jPanel3Layout.createSequentialGroup()
        .addGroup(jPanel3Layout.createParallelGroup()
          .addGroup(jPanel3Layout.createParallelGroup()
            .addGroup(jPanel3Layout.createSequentialGroup()
              .addComponent(opt_format_lbl)
              .addComponent(opt_format_cbox, GroupLayout.DEFAULT_SIZE, 100, GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
              .addComponent(opt_outputFormat_lbl)
              .addComponent(opt_outputFormat_cbox, GroupLayout.DEFAULT_SIZE, 100, GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
              .addComponent(opt_jpegQuality_lbl)
              .addComponent(opt_jpegQuality_nud, GroupLayout.DEFAULT_SIZE, 80, GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
              .addComponent(opt_alphaThresholt_lbl)
              .addComponent(opt_alphaThreashold_nud, GroupLayout.DEFAULT_SIZE, 80, GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
              .addComponent(opt_minPageWidth_lbl)
              .addComponent(opt_minPageWidth_nud, GroupLayout.DEFAULT_SIZE, 80, GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
              .addComponent(opt_minPageHeight_lbl)
              .addComponent(opt_minPageHeight_nud, GroupLayout.DEFAULT_SIZE, 80, GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
              .addComponent(opt_maxPageWidth_lab)
              .addComponent(opt_maxPageWidth_nud, GroupLayout.DEFAULT_SIZE, 80, GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
              .addComponent(opt_maxPageHeight_lbl)
              .addComponent(opt_maxPageHeight_nud, GroupLayout.DEFAULT_SIZE, 80, GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
              .addComponent(opt_paddingX_lbl)
              .addComponent(opt_paddingY_nud, GroupLayout.DEFAULT_SIZE, 80, GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
              .addComponent(opt_paddingY_lbl)
              .addComponent(opt_paddingX_nud, GroupLayout.DEFAULT_SIZE, 80, GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
              .addComponent(opt_wrapX_lbl)
              .addComponent(opt_wrapX_cbox, GroupLayout.DEFAULT_SIZE, 150, GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
              .addComponent(opt_wrapY_lbl)
              .addComponent(opt_wrapY_cbox, GroupLayout.DEFAULT_SIZE, 150, GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
              .addComponent(opt_filterMag_lbl)
              .addComponent(opt_filterMag_cbox, GroupLayout.DEFAULT_SIZE, 150, GroupLayout.PREFERRED_SIZE))
            .addGroup(jPanel3Layout.createSequentialGroup()
              .addComponent(opt_filterMin_lbl)
              .addComponent(opt_filterMin_cbox, GroupLayout.DEFAULT_SIZE, 150, GroupLayout.PREFERRED_SIZE)))
          .addGroup(jPanel3Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(opt_duplicatePadding_chk)
            .addComponent(opt_edgePadding_chk)
            .addComponent(opt_fast_chk)
            .addComponent(opt_rotation_chk)
            .addComponent(opt_stripWhitespaceY_chk)
            .addComponent(opt_stripWhitespaceX_chk)
            .addComponent(opt_ignoreBlankImages_chk)
            .addComponent(opt_ignoreIndices_chk)
            .addComponent(opt_keepExtensions_chk)
            .addComponent(opt_combineSubdirectories_chk)
            .addComponent(opt_jsonOutput_chk)
            .addComponent(opt_flattenPaths_chk)
            .addComponent(opt_pot_chk)
            .addComponent(opt_alias_chk)
            .addComponent(opt_debug_chk))));

    jPanel3Layout.linkSize(SwingConstants.HORIZONTAL, new Component[]{opt_maxPageHeight_lbl, opt_paddingY_lbl,
      opt_format_lbl, opt_jpegQuality_lbl, opt_wrapY_lbl, opt_outputFormat_lbl, opt_wrapX_lbl, opt_filterMin_lbl,
      opt_filterMag_lbl, opt_alphaThresholt_lbl, opt_paddingX_lbl, opt_minPageWidth_lbl, opt_minPageHeight_lbl,
      opt_maxPageWidth_lab});
    jPanel3Layout.linkSize(SwingConstants.HORIZONTAL, new Component[]{opt_format_cbox, opt_outputFormat_cbox});
    jPanel3Layout.linkSize(SwingConstants.HORIZONTAL, new Component[]{opt_jpegQuality_nud, opt_alphaThreashold_nud,
      opt_minPageWidth_nud, opt_minPageHeight_nud, opt_maxPageWidth_nud, opt_maxPageHeight_nud, opt_paddingX_nud,
      opt_paddingY_nud});
    jPanel3Layout.linkSize(SwingConstants.HORIZONTAL, new Component[]{opt_filterMag_cbox, opt_filterMin_cbox,
      opt_wrapX_cbox, opt_wrapY_cbox});
    jPanel3Layout.linkSize(SwingConstants.HORIZONTAL, new Component[]{opt_duplicatePadding_chk, opt_edgePadding_chk,
      opt_fast_chk, opt_rotation_chk, opt_stripWhitespaceY_chk, opt_alias_chk, opt_debug_chk, opt_ignoreBlankImages_chk,
      opt_ignoreIndices_chk, opt_keepExtensions_chk, opt_combineSubdirectories_chk, opt_jsonOutput_chk,
      opt_ignoreIndices_chk, opt_pot_chk});

    jPanel3Layout.setVerticalGroup(
      jPanel3Layout.createSequentialGroup()
        .addGroup(jPanel3Layout.createSequentialGroup()
          .addGroup(jPanel3Layout.createParallelGroup()
            .addComponent(opt_format_lbl)
            .addComponent(opt_format_cbox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
          .addGroup(jPanel3Layout.createParallelGroup()
            .addComponent(opt_outputFormat_lbl)
            .addComponent(opt_outputFormat_cbox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
          .addGroup(jPanel3Layout.createParallelGroup()
            .addComponent(opt_jpegQuality_lbl)
            .addComponent(opt_jpegQuality_nud, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
          .addGroup(jPanel3Layout.createParallelGroup()
            .addComponent(opt_alphaThresholt_lbl)
            .addComponent(opt_alphaThreashold_nud, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
          .addGroup(jPanel3Layout.createParallelGroup()
            .addComponent(opt_minPageWidth_lbl)
            .addComponent(opt_minPageWidth_nud, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
          .addGroup(jPanel3Layout.createParallelGroup()
            .addComponent(opt_minPageHeight_lbl)
            .addComponent(opt_minPageHeight_nud, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
          .addGroup(jPanel3Layout.createParallelGroup()
            .addComponent(opt_maxPageWidth_lab)
            .addComponent(opt_maxPageWidth_nud, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
          .addGroup(jPanel3Layout.createParallelGroup()
            .addComponent(opt_maxPageHeight_lbl)
            .addComponent(opt_maxPageHeight_nud, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
          .addGroup(jPanel3Layout.createParallelGroup()
            .addComponent(opt_paddingX_lbl)
            .addComponent(opt_paddingX_nud, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
          .addGroup(jPanel3Layout.createParallelGroup()
            .addComponent(opt_paddingY_lbl)
            .addComponent(opt_paddingY_nud, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
          .addGroup(jPanel3Layout.createParallelGroup()
            .addComponent(opt_wrapX_lbl)
            .addComponent(opt_wrapX_cbox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
          .addGroup(jPanel3Layout.createParallelGroup()
            .addComponent(opt_wrapY_lbl)
            .addComponent(opt_wrapY_cbox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
          .addGroup(jPanel3Layout.createParallelGroup()
            .addComponent(opt_filterMag_lbl)
            .addComponent(opt_filterMin_cbox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
          .addGroup(jPanel3Layout.createParallelGroup()
            .addComponent(opt_filterMin_lbl)
            .addComponent(opt_filterMag_cbox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
        .addGroup(jPanel3Layout.createSequentialGroup()
          .addComponent(opt_duplicatePadding_chk)
          .addComponent(opt_edgePadding_chk)
          .addComponent(opt_fast_chk)
          .addComponent(opt_rotation_chk)
          .addComponent(opt_stripWhitespaceY_chk)
          .addComponent(opt_stripWhitespaceX_chk)
          .addComponent(opt_ignoreBlankImages_chk)
          .addComponent(opt_ignoreIndices_chk)
          .addComponent(opt_keepExtensions_chk)
          .addComponent(opt_combineSubdirectories_chk)
          .addComponent(opt_jsonOutput_chk)
          .addComponent(opt_flattenPaths_chk)
          .addComponent(opt_pot_chk)
          .addComponent(opt_alias_chk)
          .addComponent(opt_debug_chk)));

    versionLabel.setText("versionLabel1");

    GroupLayout configPanelLayout = new GroupLayout(configPanel);
    configPanel.setLayout(configPanelLayout);
    configPanelLayout.setHorizontalGroup(
      configPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(configPanelLayout.createSequentialGroup()
          .addContainerGap()
          .addGroup(configPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(projectPanel, GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
            .addComponent(settingsPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(versionLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
          .addContainerGap())
    );
    configPanelLayout.setVerticalGroup(
      configPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(configPanelLayout.createSequentialGroup()
          .addContainerGap()
          .addComponent(projectPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
          .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
          .addComponent(settingsPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
          .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
          .addComponent(versionLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
          .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    getContentPane().add(configPanel, BorderLayout.WEST);

    centerPanel.setOpaque(false);

    renderPanel.setLayout(new BorderLayout());

    GroupLayout centerPanelLayout = new GroupLayout(centerPanel);
    centerPanel.setLayout(centerPanelLayout);
    centerPanelLayout.setHorizontalGroup(
      centerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(GroupLayout.Alignment.TRAILING, centerPanelLayout.createSequentialGroup()
          .addComponent(renderPanel, GroupLayout.DEFAULT_SIZE, 510, Short.MAX_VALUE)
          .addContainerGap())
    );
    centerPanelLayout.setVerticalGroup(
      centerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(centerPanelLayout.createSequentialGroup()
          .addContainerGap()
          .addComponent(renderPanel, GroupLayout.DEFAULT_SIZE, 584, Short.MAX_VALUE)
          .addContainerGap())
    );

    getContentPane().add(centerPanel, BorderLayout.CENTER);

    pack();
  }// </editor-fold>//GEN-END:initComponents

  // Variables declaration - do not modify//GEN-BEGIN:variables
  private JButton browseInputBtn;
  private JButton browseOutputBtn;
  private JPanel centerPanel;
  private JLabel commentLabel;
  private JPanel configPanel;
  private JButton copySettingsBtn;
  private JButton deletePackBtn;
  private JTextField filenameField;
  private JPanel headerPanel;
  private JPanel headerPanel1;
  private JTextField inputField;
  private JLabel jLabel1;
  private JLabel opt_maxPageHeight_lbl;
  private JLabel jLabel11;
  private JLabel jLabel12;
  private JLabel opt_paddingY_lbl;
  private JLabel opt_format_lbl;
  private JLabel opt_jpegQuality_lbl;
  private JLabel opt_wrapY_lbl;
  private JLabel opt_outputFormat_lbl;
  private JLabel opt_wrapX_lbl;
  private JLabel opt_filterMin_lbl;
  private JLabel opt_filterMag_lbl;
  private JLabel opt_alphaThresholt_lbl;
  private JLabel opt_paddingX_lbl;
  private JLabel opt_minPageWidth_lbl;
  private JLabel opt_minPageHeight_lbl;
  private JLabel opt_maxPageWidth_lab;
  private JPanel jPanel1;
  private JPanel jPanel2;
  private JPanel jPanel3;
  private JScrollPane jScrollPane1;
  private JToolBar jToolBar1;
  private JToolBar jToolBar2;
  private JToolBar jToolBar4;
  private JButton moveDownPackBtn;
  private JButton moveUpPackBtn;
  private JButton newPackBtn;
  private JButton openProjectBtn;
  private JCheckBox opt_alias_chk;
  private JSpinner opt_alphaThreashold_nud;
  private JCheckBox opt_debug_chk;
  private JCheckBox opt_duplicatePadding_chk;
  private JCheckBox opt_edgePadding_chk;
  private JCheckBox opt_fast_chk;
  private JComboBox opt_filterMag_cbox;
  private JComboBox opt_filterMin_cbox;
  private JComboBox opt_format_cbox;
  private JCheckBox opt_ignoreBlankImages_chk;
  private JCheckBox opt_ignoreIndices_chk;
  private JCheckBox opt_keepExtensions_chk;
  private JCheckBox opt_combineSubdirectories_chk;
  private JCheckBox opt_jsonOutput_chk;
  private JCheckBox opt_flattenPaths_chk;
  private JSpinner opt_jpegQuality_nud;
  private JSpinner opt_maxPageHeight_nud;
  private JSpinner opt_maxPageWidth_nud;
  private JSpinner opt_minPageHeight_nud;
  private JSpinner opt_minPageWidth_nud;
  private JComboBox opt_outputFormat_cbox;
  private JSpinner opt_paddingX_nud;
  private JSpinner opt_paddingY_nud;
  private JCheckBox opt_pot_chk;
  private JCheckBox opt_rotation_chk;
  private JCheckBox opt_stripWhitespaceX_chk;
  private JCheckBox opt_stripWhitespaceY_chk;
  private JComboBox opt_wrapX_cbox;
  private JComboBox opt_wrapY_cbox;
  private JTextField outputField;
  private JButton packAllBtn;
  private JButton packSelectedBtn;
  private JList packsList;
  private JPanel projectPanel;
  private JButton renamePackBtn;
  private JPanel renderPanel;
  private JButton saveProjectBtn;
  private JPanel settingsPanel;
  private aurelienribon.utils.VersionLabel versionLabel;
  // End of variables declaration//GEN-END:variables
}
